import request from "../utils/request"


export const getDictionary = (typeKey) => {
    return request({
        method: 'get',
        data: {
            typeKey: typeKey
        },
        url:'/portal/recourse/get_dictionary_datas_typekey'
    })
}

/**
 * 获取我的求职意向
 */
export const getMyJobIntention = () => {
    return request({
        method: 'get',
        url: '/portal/resume/my_job_intention'
    })
}

/**
 * 获取我的简历
 */
export const getMyResume = () => {
    return request({
        method: 'get',
        url: '/portal/resume/my_resume'
    })
}

/**
 * 保存个人优势
 * @param {Object} data - 请求数据
 * @param {string} data.advantage - 个人优势
 * @param {string} data.advantageHtml - 个人优势html格式
 */
export const saveAdvantage = (data) => {
    return request({
        method: 'post',
        url: '/portal/resume/modify',
        data: {
            advantage: data.advantage,
            advantageHtml: data.advantageHtml
        }
    })
}

/**
 * 保存求职状态
 * @param {string} status - 求职状态
 */
export const saveJobSeekStatus = (status) => {
    return request({
        method: 'post',
        url: '/portal/resume/modify',
        data: {
            status: status
        }
    })
}

/**
 * 刷新简历
 * @returns {Promise} - 返回刷新结果
 */
export const refreshResume = () => {
    return request({
        method: 'post',
        url: '/portal/resume/refresh'
    })
}





/**
 * 提交工作经历
 * @param {} data 
 * @returns 
 */
export const submitWorkExperience = (data) => {
    return request({
        method: 'post',
        url: '/portal/resume/work_experience/submit',
        data
    })
}

/**
 * 删除工作经历
 * @param {string} id - 工作经历ID
 */
export const deleteWorkExperience = (id) => {
    return request({
        method: 'get',
        url: '/portal/resume/work_exp/del',
        data: {
            workExperienceId: id
        }
    })
}

/**
 * 获取工作经历详情
 * @param {string} id - 工作经历ID
 */
export const getWorkExperienceDetail = (id) => {
    return request({
        method: 'get',
        url: '/portal/resume/work_exp/detail',
        data: {
            workExperienceId: id
        }
    })
}

/**
 * 提交项目经历
 * @param {Object} data - 请求数据
 */
export const submitProjectExperience = (data) => {
    return request({
        method: 'post',
        url: '/portal/resume/proj_experience/submit',
        data
    })
}

/**
 * 删除项目经历
 * @param {string} id - 项目经历ID
 */
export const deleteProjectExperience = (id) => {
    return request({
        method: 'get',
        url: '/portal/resume/proj_exp/del',
        data: {
            projExperienceId: id
        }
    })
}

/**
 * 获取项目经历详情
 * @param {string} id - 项目经历ID
 */
export const getProjectExperienceDetail = (id) => {
    return request({
        method: 'get',
        url: '/portal/resume/proj_exp/detail',
        data: {
            projExperienceId: id
        }
    })
}

/**
 * 提交教育经历
 * @param {Object} data - 请求数据
 */
export const submitEducation = (data) => {
    return request({
        method: 'post',
        url: '/portal/resume/education/submit',
        data
    })
}

/**
 * 删除教育经历
 * @param {string} id - 教育经历ID
 */
export const deleteEducation = (id) => {
    
    return request({
        method: 'get',
        url: '/portal/resume/education/del',
        data: {
            educationId: id
        }
    })
}

/**
 * 获取教育经历详情
 * @param {string} id - 教育经历ID
 */
export const getEducationDetail = (id) => {
    return request({
        method: 'get',
        url: '/portal/resume/education/detail',
        data: {
            educationId: id
        }
    })
}

/**
 * 提交求职期望
 * @param {Object} data - 请求数据
 */
export const submitWorkExpectation = (data) => {
    return request({
        method: 'post',
        url: '/portal/resume/work_expect/submit',
        data
    })
}

/**
 * 删除求职期望
 * @param {string} id - 求职期望ID
 */
export const deleteWorkExpectation = (id) => {
    return request({
        method: 'get',
        url: '/portal/resume/work_expect/del',
        data: {
            workExpectId: id
        }
    })
}

/**
 * 获取求职期望详情
 * @param {string} id - 求职期望ID
 */
export const getWorkExpectationDetail = (id) => {
    return request({
        method: 'get',
        url: '/portal/resume/work_expect/detail',
        data: {
            workExpectId: id
        }
    })
}

/**
 * 保存资格证书
 * @param {string} credentials - 资格证书（逗号分隔的字符串）
 */
export const saveCredentials = (credentials) => {
    return request({
        method: 'post',
        url: '/portal/resume/modify',
        data: {
            credentials: credentials
        }
    })
}

/**
 * 保存专业技能
 * @param {string} skills - 专业技能（逗号分隔的字符串）
 */
export const saveSkills = (skills) => {
    return request({
        method: 'post',
        url: '/portal/resume/modify',
        data: {
            skills: skills
        }
    })
}

/**
 * 获取他人简历详情（HR查看候选人简历）
 * @param {string} userId - 用户ID
 */
export const getResumeDetail = (userId) => {
    return request({
        method: 'get',
        url: '/portal/resume/detail',
        data: {
            userId: userId
        }
    })
}

/**
 * HR收藏简历（通过resumeId）
 * @param {string} resumeId - 简历ID
 */
export const hrCollectResume = (resumeId) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_collect',
        data: {
            resumeId: resumeId
        }
    })
}

/**
 * HR取消收藏简历（通过resumeId）
 * @param {string} resumeId - 简历ID
 */
export const hrUncollectResume = (resumeId) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_uncollect',
        data: {
            resumeId: resumeId
        }
    })
}

/**
 * 检查HR是否已收藏简历（通过resumeId）
 * @param {string} resumeId - 简历ID
 * @returns {Promise<boolean>} 是否已收藏
 */
export const hrIsCollected = (resumeId) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_is_collected',
        data: {
            resumeId: resumeId
        }
    })
}

/**
 * HR收藏简历（通过resumeExpId）
 * @param {string} resumeExpId - 求职期望ID
 */
export const hrCollectResumeByExpId = (resumeExpId) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_collect',
        data: {
            resumeExpId: resumeExpId
        }
    })
}

/**
 * HR取消收藏简历（通过resumeExpId）
 * @param {string} resumeExpId - 求职期望ID
 */
export const hrUncollectResumeByExpId = (resumeExpId) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_uncollect',
        data: {
            resumeExpId: resumeExpId
        }
    })
}

/**
 * 检查HR是否已收藏简历（通过resumeExpId）
 * @param {string} resumeExpId - 求职期望ID
 * @returns {Promise<boolean>} 是否已收藏
 */
export const hrIsCollectedByExpId = (resumeExpId) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_is_collected',
        data: {
            resumeExpId: resumeExpId
        }
    })
}

/**
 * 获取HR收藏的简历列表
 * @param {Object} params - 分页参数
 * @param {number} params.pageNo - 页码，默认1
 * @param {number} params.pageSize - 页大小，默认10
 * @returns {Promise} 收藏简历列表
 */
export const getHrCollectedResumeList = (params = {}) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_collected/list',
        data: {
            pageNo: params.pageNo || 1,
            pageSize: params.pageSize || 10
        }
    })
}

/**
 * 获取HR收藏的简历总数
 * @returns {Promise<number>} 收藏简历总数
 */
export const getHrCollectedResumeCount = () => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_collected/count',
        showLoading: false // 不显示加载动画
    })
}

/**
 * HR记录浏览简历
 * @param {string} resumeExpectId - 求职期望ID
 * @returns {Promise} 响应结果
 */
export const hrViewRecord = (resumeExpectId) => {
    return request({
        method: 'post',
        url: '/portal/resume/hr_view_record?resumeExpectId=' + resumeExpectId,
        showLoading: false // 不显示加载动画，后台操作
    })
}

/**
 * HR获取浏览记录列表
 * @param {Object} params - 分页参数
 * @param {number} params.pageNo - 页码，默认1
 * @param {number} params.pageSize - 页大小，默认10
 * @returns {Promise} 浏览记录列表
 */
export const getHrViewRecordList = (params = {}) => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_view/list',
        data: {
            pageNo: params.pageNo || 1,
            pageSize: params.pageSize || 10
        }
    })
}

/**
 * HR获取浏览记录总数
 * @returns {Promise<number>} 浏览记录总数
 */
export const getHrViewRecordCount = () => {
    return request({
        method: 'get',
        url: '/portal/resume/hr_view/count',
        showLoading: false // 不显示加载动画
    })
}

/**
 * 根据求职期望ID获取简历详情（HR查看求职者的具体求职期望简历）
 * @param {string} resumeExpId - 求职期望ID
 */
export const getResumeDetailByWorkExp = (resumeExpId) => {
    return request({
        method: 'get',
        url: `/portal/resume/detail_by_work_exp?resumeExpId=${resumeExpId}`,
    })
}


export const getResumeDetailByResumeId = (resumeId) => {
    return request({
        method: 'get',
        url: `/portal/resume/detail?resumeId=${resumeId}`,
    })
}


/**
 * 获取被HR查看次数
 * @returns {Promise<number>} 被查看的次数
 */
export const getJobSeekerViewedCount = () => {
    return request({
        method: 'get',
        url: '/portal/resume/job_seeker_viewed_by_hr/count',
        showLoading: false // 不显示加载动画，后台静默获取
    })
}

/**
 * 获取查看我的HR列表
 * @param {Object} params - 分页参数
 * @param {number} params.pageNo - 页码，默认1
 * @param {number} params.pageSize - 页大小，默认10
 * @returns {Promise} HR列表
 */
export const getJobSeekerViewedByHrList = (params = {}) => {
    return request({
        method: 'get',
        url: '/portal/resume/job_seeker_viewed_by_hr/list',
        data: {
            pageNo: params.pageNo || 1,
            pageSize: params.pageSize || 10
        }
    })
}
